package com.example.swaggerDemo.controller;

import com.example.swaggerDemo.entity.MsgEntity;
import com.example.swaggerDemo.entity.userbyordeView;
import com.example.swaggerDemo.service.UserbyordeViewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.List;

@Api("经纪人服务服务")
@RestController
@RequestMapping(value="/agentOrder")
public class AgentOrderController {

    @Autowired
    private UserbyordeViewService Service;
    @ApiOperation(value="经纪人查询名下需要处理的订单",notes="经纪人查询名下需要处理的订单")
    @ResponseBody
    @RequestMapping(value="/findUpUserIdByType",method= RequestMethod.POST)
    public  Object findUpUserIdByType(@RequestParam("upuserid") String upuserid,
                                      @RequestParam("typedata") String typedata,
                                      @RequestParam("statustype") String statustype,
                                      @RequestParam("pageindex") int pagindex,
                                      @RequestParam("pagesize") int pagesize,
                                      @RequestParam("username") String username) throws SQLException
    {
        MsgEntity msg=new MsgEntity();
        try {
            List<userbyordeView> dto = Service.findUpUserIdByType(upuserid,typedata,statustype,pagindex,pagesize,username);
            if ( dto.size()>0){
                msg.msg="数据查询成功";
                msg.code=true;
                msg.object=dto;
            }
            else
            {
                msg.msg="没有查询导数据";
                msg.code=false;
                msg.object=dto;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return msg;
    }



    @ApiOperation(value="经纪人查询名下需要处理的订单指定订单类型",notes="经纪人查询名下需要处理的订单指定订单类型")
    @ResponseBody
    @RequestMapping(value="/findUserIdByType",method= RequestMethod.POST)
    public  Object findUserIdByType(@RequestParam("upuserid") String upuserid,
                                      @RequestParam("typedata") String typedata,
                                      @RequestParam("pageindex") int pagindex,
                                      @RequestParam("pagesize") int pagesize) throws SQLException
    {
        MsgEntity msg=new MsgEntity();
        try {
            List<userbyordeView> dto = Service.findUserIdByType(upuserid,typedata,pagindex,pagesize);
            if ( dto.size()>0){
                msg.msg="数据查询成功";
                msg.code=true;
                msg.object=dto;
            }
            else
            {
                msg.msg="没有查询导数据";
                msg.code=false;
                msg.object=dto;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return msg;
    }

    @ApiOperation(value="经纪人查询名下需要处理的协助订单",notes="经纪人查询名下需要处理的协助订单")
    @ResponseBody
    @RequestMapping(value="/findAssitantidByType",method= RequestMethod.POST)
    public  Object findAssitantidByType(@RequestParam("assitantid") String assitantid,
                                      @RequestParam("statustype") String statustype,
                                      @RequestParam("pageindex") int pagindex,
                                      @RequestParam("pagesize") int pagesize,
                                        @RequestParam("username") String username) throws SQLException
    {
        MsgEntity msg=new MsgEntity();
        try {
            List<userbyordeView> dto = Service.findAssitantidByType(assitantid,statustype,pagindex,pagesize,username);
            if ( dto.size()>0){
                msg.msg="数据查询成功";
                msg.code=true;
                msg.object=dto;
            }
            else
            {
                msg.msg="没有查询导数据";
                msg.code=false;
                msg.object=dto;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return msg;
    }
}
